import request from '@/utils/request'
import { prefilter } from '@/utils'
/**
 * 根据区域ID查询下一级所有行政区域
 */
export function getAreaList (params = {}) {
  prefilter(params)
  return request({
    url: '/portal-service/area/list',
    method: 'get',
    params
  })
}

// 增加地区
export function addAreaSingle (data = {}) {
  prefilter(data)
  return request({
    url: '/portal-service/area/add',
    method: 'post',
    data
  })
}

// 批量增加地区
export function addAreaBatch (data = []) {
  return request({
    url: '/portal-service/area/addBatch',
    method: 'post',
    headers: {
      'Content-Type': 'application/json;charset=utf-8'
    },
    data
  })
}

// 查看地区详情
export function getAreaDetail (data = {}) {
  prefilter(data)
  return request({
    url: '/portal-service/area/detail ',
    method: 'post',
    data
  })
}

// 修改地区详情
export function updateAreaDetail (data = {}) {
  prefilter(data)
  return request({
    url: '/portal-service/area/update ',
    method: 'post',
    data
  })
}

// 删除地区
export function deleteArea (data = {}) {
  prefilter(data)
  return request({
    url: '/portal-service/area/delete ',
    method: 'post',
    data
  })
}

/**
 * 数据字典项
 */
// 查看数据字典项列表
export function getDictionaryItem (data = {}) {
  prefilter(data)
  return request({
    url: '/govern-service/dictionaryItem/list',
    method: 'post',
    data
  })
}

// 增加数据字典项
export function addDictionaryItem (data = {}) {
  prefilter(data)
  data.deleteStatus = 'N'// 表示状态为 未删除
  return request({
    url: '/govern-service/dictionaryItem/add',
    method: 'post',
    data
  })
}

// 查看数据字典项详情
export function getDictionaryItemDetail (data = {}) {
  prefilter(data)
  return request({
    url: '/govern-service/dictionaryItem/detail',
    method: 'post',
    data
  })
}

// 修改数据字典项详情
export function updateDictionaryItem (data = {}) {
  prefilter(data)
  return request({
    url: '/govern-service/dictionaryItem/update',
    method: 'post',
    data
  })
}

// 删除数据字典项详情
export function deleteDictionaryItem (data = {}) {
  prefilter(data)
  return request({
    url: '/govern-service/dictionaryItem/delete',
    method: 'post',
    data
  })
}

/**
 * 数据字典值
 */
// 根据数据项itemId查看数据字典值列表
export function getDictionaryDataById (params = {}) {
  prefilter(params)
  return request({
    url: '/govern-service/dictionaryData/listDictionaryDataByItemId',
    method: 'get',
    params
  })
}

// 增加数据字典值
export function addDictionaryData (data = {}) {
  prefilter(data)
  data.deleteStatus = 'N'// 表示状态为 未删除
  return request({
    url: '/govern-service/dictionaryData/add',
    method: 'post',
    data
  })
}

// 查看数据字典值详情
export function getDictionaryDataDetail (data = {}) {
  prefilter(data)
  return request({
    url: '/govern-service/dictionaryData/detail',
    method: 'post',
    data
  })
}

// 修改数据字典值详情
export function updateDictionaryData (data = {}) {
  prefilter(data)
  return request({
    url: '/govern-service/dictionaryData/update',
    method: 'post',
    data
  })
}

// 删除数据字典值
export function deleteDictionaryData (data = {}) {
  prefilter(data)
  return request({
    url: '/govern-service/dictionaryData/delete',
    method: 'post',
    data
  })
}

/**
 * 参数设置
 */
// 查看所有应用
export function getDockerAppList (data = {}) {
  prefilter(data)
  return request({
    url: '/docker-service/dockerapp/list',
    method: 'post',
    data
  })
}

// 配置列表
export function getConfigwebList (data = {}) {
  prefilter(data)
  return request({
    url: '/config-web-service/configweb/list',
    method: 'post',
    data
  })
}

// 新增配置
export function configwebAdd (data = {}) {
  prefilter(data)
  return request({
    url: '/config-web-service/configweb/add',
    method: 'post',
    data
  })
}

// 修改配置
export function updateConfigweb (data = {}) {
  prefilter(data)
  return request({
    url: '/config-web-service/configweb/update',
    method: 'post',
    data
  })
}

// 删除配置
export function deleteConfigweb (data = {}) {
  prefilter(data)
  return request({
    url: '/config-web-service/configweb/delete',
    method: 'post',
    data
  })
}

// 系统配置刷新
export function refreshConfig (data = {}) {
  prefilter(data)
  return request({
    url: '/config-web-service/configweb/updateAll',
    method: 'post',
    data
  })
}

/**
 * 菜单管理
 */
// 资源列表
export function getResourceList (data = {}) {
  prefilter(data)
  return request({
    url: '/portal-service/resource/list',
    method: 'post',
    data
  })
}

// 增加资源
export function addResource (data = {}) {
  prefilter(data)
  data.deleteStatus = 'N'// 表示状态为 未删除
  return request({
    url: '/portal-service/resource/add',
    method: 'post',
    data
  })
}

// 修改资源
export function updateResource (data = {}) {
  prefilter(data)
  return request({
    url: '/portal-service/resource/update',
    method: 'post',
    data
  })
}

// 删除资源
export function deleteResource (data = {}) {
  prefilter(data)
  return request({
    url: '/portal-service/resource/delete',
    method: 'post',
    data
  })
}

/**
 * 角色管理
 */
// 角色列表
export function getRoleList (data = {}) {
  prefilter(data)
  return request({
    url: '/portal-service/role/list',
    method: 'post',
    data
  })
}

// 增加角色
export function addRole (data = {}) {
  prefilter(data)
  data.deleteStatus = 'N'// 表示状态为 未删除
  return request({
    url: '/portal-service/role/add',
    method: 'post',
    data
  })
}

// 角色详情
export function getRoleDetail (data = {}) {
  prefilter(data)
  return request({
    url: '/portal-service/role/detail',
    method: 'post',
    data
  })
}

// 修改角色
export function updateRole (data = {}) {
  prefilter(data)
  return request({
    url: '/portal-service/role/update',
    method: 'post',
    data
  })
}

// 删除角色
export function deleteRole (data = {}) {
  prefilter(data)
  return request({
    url: '/portal-service/role/delete',
    method: 'post',
    data
  })
}

/**
 * 角色资源管理
 */
// 角色资源列表
export function getRoleResourceList (data = {}) {
  prefilter(data)
  return request({
    url: '/portal-service/role/listResource',
    method: 'post',
    data
  })
}

// 添加角色资源
export function addRoleResource (data = {}) {
  prefilter(data)
  return request({
    url: '/portal-service/roleResource/addAll',
    method: 'post',
    data
  })
}

/**
 * 用户管理
 */
// 用户列表
export function getUserList (data = {}) {
  prefilter(data)
  return request({
    url: '/portal-service/user/list',
    method: 'post',
    data
  })
}

// 增加用户
export function addUser (data = {}) {
  prefilter(data)
  data.deleteStatus = 'N'// 表示状态为 未删除
  return request({
    url: '/portal-service/user/add',
    method: 'post',
    data
  })
}

// 用户详情
export function getUserDetail (data = {}) {
  prefilter(data)
  return request({
    url: '/portal-service/user/detail',
    method: 'post',
    data
  })
}

// 修改用户
export function updateUser (data = {}) {
  prefilter(data)
  return request({
    url: '/portal-service/user/update',
    method: 'post',
    data
  })
}

// 删除用户
export function deleteUser (data = {}) {
  prefilter(data)
  return request({
    url: '/portal-service/user/delete',
    method: 'post',
    data
  })
}
